#ifndef PROCESSORMANAGER_H
#define PROCESSORMANAGER_H

#include "IProcessor.h"
#include <vector>
#include <string>

#ifdef __cplusplus
extern "C" {
#endif

class ProcessorManager
{
  public:

    /// Destructor
    __declspec(dllexport) ~ProcessorManager() {
      for(ProcessorVector::reverse_iterator It = m_Processors.rbegin();
          It != m_Processors.rend();
          ++It)
        delete *It;
    }

    /// Allows plugins to add new graphics drivers
    __declspec(dllexport) void addProcessor(std::auto_ptr<IProcessor> P) {
      m_Processors.push_back(P.release());
    }

    /// Get the total number of registered graphics drivers
    __declspec(dllexport) size_t getProcessorCount() const {
      return m_Processors.size();
    }
    /// Access a driver by its index
    __declspec(dllexport) IProcessor &getProcessor(size_t Index) {
      return *m_Processors.at(Index);
    }

	__declspec(dllexport) void configAll(asIScriptEngine *engine)
	{
      for(ProcessorVector::reverse_iterator It = m_Processors.rbegin();
          It != m_Processors.rend();
          ++It)
	  {
		  (*It)->config(engine);
	  }
	}
  private:
    /// A vector of graphics drivers
    typedef std::vector<IProcessor *> ProcessorVector;
    ProcessorVector m_Processors; ///< All available graphics drivers
};


#ifdef __cplusplus
}
#endif

#endif